<template>
	<view>
		<view class="subtitle">{{listTitle}}</view>
		<scroll-view scroll-x="true" class="scroll-box">
			<view class="item-box" v-for="(item,index) in goodsList" :key="index"
				@click="chooseItem(item)">
				<view class="imgbox">
					<image :src="item.image"  mode="" class="img"></image>
				</view>
				<view class="item-name">{{item.title}}</view>
				<view class="item-descr"><text style="font-size: 24rpx;">券</text>{{item.price}}</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props: {
			listTitle: {
				type: String,
				default: ''
			},
			goodsList: {
				type: Array,
				default: () => []
			},
			imgWidth: {
				type: Number,
				default: 128
			},
			imgHeight: {
				type: Number,
				default: 128
			}
		},
		data() {
			return {}
		},
		methods: {
			//点击某个item
			chooseItem(item) {
				this.$emit("clickItem", item)
			}
		}
	}
</script>

<style>
	/deep/ ::-webkit-scrollbar {
		width: 0;
		height: 0;
		color: transparent;
		display: none;
	}
</style>
<style scoped>
	.subtitle {
		/* padding: 16rpx 32rpx; */
		font-size: 32rpx;
		font-weight: bold;
		color: #333333;
		line-height: 48rpx;
	}
	.img{
		position: absolute;
		top: 0;
		right: 0;
		left: 0;
		bottom: 0;
		margin: auto auto;
		width: 80%;
		height: 80%;
	}
	.imgbox{
		width: 152rpx;
		height: 152rpx;
		position: relative;
		background: linear-gradient( 180deg, #F9F9F9 25%, rgba(246,248,247,0) 100%);
		border-radius: 16rpx 16rpx 0rpx 0rpx;
	}
	.scroll-box {
		display: flex;
		white-space: nowrap;
		width: 100%;
		min-height: 228rpx;
		/* margin-top: 24rpx; */
	}

	.item-box {
		display: inline-block;
		width: 152rpx;
		height: 222rpx;
		/* padding-right: 20rpx; */
		
		margin-right: 20rpx;
		border-radius: 16rpx 16rpx 0rpx 0rpx;
		/* border: 4rpx solid #FFFFFF; */
		/* box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.1); */
		/* text-align: center; */
	}

	.item-name {
		width: 152rpx; /* 确保宽度为100%，以便省略号效果能正确应用 */
		font-size: 28rpx;
		height: 28rpx;
		/* padding: 5rpx; */
		font-weight: Medium;
		font-family: "PingFang SC", sans-serif; /* 更改以确保跨浏览器兼容性 */
		color: #1E1E1E;
		line-height: 28rpx;
		overflow: hidden; /* 隐藏超出部分 */
		text-overflow: ellipsis; /* 超出文本用省略号表示 */
		white-space: normal; /* 文本不换行 */
		display: -webkit-box; /* 用于支持老Webkit内核的浏览器 */
		-webkit-box-orient: vertical; /* 设置或检索伸缩盒对象的子元素的排列方式 */
		-webkit-line-clamp: 1; /* 限制在一个块元素显示的内容的行数 */
		text-align: left;
		margin-top: 10rpx;
		
		
	}

	.item-descr {
		display: table;
		width: 100%;
		font-size: 24rpx;
		line-height: 22rpx;
		white-space: pre-wrap;
		color: #36BE6A;
		margin-top: 18rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		text-align: left;
		/* overflow: hidden; */
	}

	.bg0 {
		background: linear-gradient(180deg, #FFE8C2 0%, #FFFFFF 100%);
	}

	.bg1 {
		background: linear-gradient(180deg, #D3DBFF 0%, #FFFFFF 100%);
	}

	.bg2 {
		background: linear-gradient(360deg, #FFFFFF 0%, #D7C4FF 100%);
	}

	.bg3 {
		background: linear-gradient(180deg, #FFD3D3 0%, #FFFFFF 100%);
	}

	.bg4 {
		background: linear-gradient(180deg, #D3FFFB 0%, #FFFFFF 100%);
	}

	.bg5 {
		background: linear-gradient(180deg, #D3FFE7 0%, #FFFFFF 100%);
	}

	.bg6 {
		background: linear-gradient(180deg, #FFD3FB 0%, #FFFFFF 100%);
	}
</style>